using HMCollada.FX;
using HMCollada.Core;
using System.Xml;

namespace HMCollada.Core {
    internal struct HMColladaInstanceGeometry {
        internal string sid;
        internal string name;
        internal string url;
        internal HMColladaBindMaterial bind_material;
    }
}

namespace HMCollada {
    internal partial class HMColladaLoader {
        private static HMColladaInstanceGeometry LoadInstanceGeometry() {
            HMColladaInstanceGeometry newInstanceGeometry = new HMColladaInstanceGeometry();
            newInstanceGeometry.sid = colladaReader.GetAttribute("sid");
            newInstanceGeometry.name = colladaReader.GetAttribute("name");
            newInstanceGeometry.url = colladaReader.GetAttribute("url");

            if (!colladaReader.IsEmptyElement) colladaReader.Read();
            do {
                if (colladaReader.NodeType != XmlNodeType.EndElement) {
                    switch (colladaReader.Name) {
                        case "bind_material": newInstanceGeometry.bind_material = LoadBindMaterial(); break;
                    }
                }

                if (!colladaReader.IsEmptyElement) colladaReader.Read();
            } while (colladaReader.Name != "instance_geometry");

            if (colladaReader.IsEmptyElement) colladaReader.Read();
            return newInstanceGeometry;
        }
    }
}